import pandas as pd
import numpy as np

t = pd.Series([1, 2, 3, 4, 5, 6, 7])
print('生成series', t)
print('生成series的类型', type(t))

t2 = pd.Series([1, 2, 3, 4, 5], index=list('abced'))
print(t2)

temp_dict = {'name': 'xiaohong', 'age': 20, 'tel': '10086'}
t3 = pd.Series(temp_dict)
print(t3)

print(t2.dtype, t3.dtype)
print(t3['age'])

d1 = pd.DataFrame(np.arange(12).reshape(3, 4))
print(d1)

d1 = {'name': ['xiaoming', 'xiaohong'], 'age': [20, 22], 'tel': [10086, 10010]}
print('创建dataframe-字典', pd.DataFrame(d1))

d2 = [{'name': 'xiaohong', 'age': 20, 'tel': 10086}, {'name': 'xiaohong', 'age': 22, 'tel': 10010}]
print('创建dataframe-列表', pd.DataFrame(d2))

print('形状--', pd.DataFrame(d2).shape)
print('列数据类型--', pd.DataFrame(d2).dtypes)
print('数据维度--', pd.DataFrame(d2).ndim)

t3 = pd.DataFrame(np.arange(12).reshape(3, 4), index=list('abc'), columns=list('WXYZ'))

print('loc定位:',t3.loc["a", "Z"])
print('iloc定位:',t3.iloc[1,:])

